/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork;

import java.util.Vector;

/**
 *
 * @author DANTRUONG
 */
public class ReadMap {
    int m_Height;
    int m_Width;
    int m_Map[][];
    int m_Figures[] = new int[6];
    
    public int getHeight() {
        return m_Height;
    }
    public int getTime(){
        return m_Figures[5];
    }
    public int[][] getMap() {
        return m_Map;
    }

    public int getWidth() {
        return m_Width;
    }

    public void setHeight(int m_Height) {
        this.m_Height = m_Height;
    }

    public void setWidth(int m_Width) {
        this.m_Width = m_Width;
    }

    public void setMap(int[][] m_Map) {
        this.m_Map = m_Map;
    }

    public int[] getFigures() {
        return m_Figures;
    }

    public void setFigures(int[] m_Figures) {
        this.m_Figures = m_Figures;
    }
    
    private String[] split(String original,String separator){
        
        Vector nodes = new Vector();
        int index = original.indexOf(separator);
        while(index>=0){
            nodes.addElement(original.substring(0, index));
            original = original.substring(index+separator.length());
            index = original.indexOf(separator);
        }
        nodes.addElement(original);
        String[] result = new String[nodes.size()];
        if( nodes.size()>0 ) {
            for(int i=0; i<nodes.size(); i++){
                result[i] = (String)nodes.elementAt(i);
            }
        }
        return result;
    }
    public void Read(String _TextFile){
        
        String StrBuffer = null;
        int Row = 0;
        String[] StrTemp = null;
        
        LoadLine Load = new LoadLine(_TextFile);
        
        if((StrBuffer = Load.readLine()) != null){
            StrTemp = split(StrBuffer," ");
            for(int i=0; i<6;i++){
                m_Figures[i]= Integer.parseInt(StrTemp[i]);
            }
        }
        m_Map = new int[m_Figures[3]][ m_Figures[2]];
        m_Height = m_Figures[2];
        m_Width = m_Figures[3];
        
        while((StrBuffer = Load.readLine()) != null){
            StrTemp = split(StrBuffer," ");
            for(int i=0; i<m_Figures[3];i++)
                m_Map[i][Row] = Integer.parseInt(StrTemp[i]);
            Row++;
        }
    }
}
